import axios from "axios";
import { Message } from "element-ui";
const proxy = "";
const request = (config) => {
  const installce = axios.create({
    baseURL: proxy,
    timeout: 30000,
  });
  return installce(config)
    .then((res) => {
      const status = res.status;
      if (status === 200) {
        return Promise.resolve(res.data);
      }
      return Promise.reject(res);
    })
    .catch((error) => {
      console.log(error);
      if (error.message !== "CANCEL") {
        Message({
          type: "error",
          message:
            error.response.message || error.response.status + " " + error.response.statusText,
          duration: 2500,
        });
      }
      return Promise.reject(error);
    });
};

export default request;
